package com.xishu.entity.customer;

import com.xishu.annotation.dao.CustomerNotModify;
import com.xishu.annotation.dao.DefaultValue;
import com.xishu.annotation.dao.FieldMapping;
import com.xishu.annotation.dao.Search;
import com.xishu.annotation.lang.Lang;
import com.xishu.bo.TicketAndLimit;
import com.xishu.entity.AbstractEntity;
import com.xishu.entity.shop.DiscountTicket;
import io.swagger.annotations.ApiModelProperty;

import javax.persistence.*;
import java.util.List;

/**
 * 营销任务
 */
@Entity(name = "market_task")
@Table(indexes = {@Index(columnList = "companyId")})
public class MarketTask extends AbstractEntity {
    @ApiModelProperty(value = "归属哪一个公司")
    @CustomerNotModify
    private Long companyId;

    @ApiModelProperty(value = "任务名称")
    @Lang(key = "name")
    private String taskName_zh;

    @ApiModelProperty(value = "任务名称")
    @Lang(key = "name")
    private String taskName_en;

    //收件人是先保存列表，还是保存条件待定
    @ApiModelProperty(value = "是否发送邮件")
    @DefaultValue(defaultValue = "false")
    @CustomerNotModify
    private Boolean email;

    @ApiModelProperty(value = "是否发送短信")
    @DefaultValue(defaultValue = "false")
    @CustomerNotModify
    private Boolean sms;

    @ApiModelProperty(value = "短信采用中文发送")
    @DefaultValue(defaultValue = "false")
    private Boolean smsZh;

    @ApiModelProperty(value = "短信采用英文发送")
    @DefaultValue(defaultValue = "false")
    private Boolean smsEn;

    @ApiModelProperty(value = "邮件的标题")
    @CustomerNotModify
    private String emailTitle;

    @ApiModelProperty(value = "邮件的内容")
    @CustomerNotModify
    @Lob
    @Column(columnDefinition = "MEDIUMTEXT")
    private String emailContent;

    @ApiModelProperty(value = "短信模板")
    @CustomerNotModify
    private Long smsId;

    @ApiModelProperty(value = "自动发送")
    @CustomerNotModify
    private Boolean autoSend;

    @Transient
    @FieldMapping(desField = "periodTimeConfigJson", serialize = true, isObject = true)
    private PeriodTimeConfig periodTimeConfig;

    @ApiModelProperty(value = "是否是周期性任务")
    @CustomerNotModify
    private Boolean periodTask;

    @FieldMapping(desField = "periodTimeConfig", serialize = false, genericType = "com.xishu.entity.customer.PeriodTimeConfig", isObject = true)
    @Lob
    @Column(columnDefinition = "MEDIUMTEXT")
    @CustomerNotModify
    private String periodTimeConfigJson;

    @ApiModelProperty(value = "所有相关的会员ID列表")
    @Lob
    @Column(columnDefinition = "MEDIUMTEXT")
    @FieldMapping(desField = "customerIdList", serialize = false, genericType = "java.lang.Long")
    @CustomerNotModify
    private String customerIdListJson;

    @Transient
    @ApiModelProperty(value = "所有相关的会员ID列表")
    @FieldMapping(desField = "customerIdListJson", serialize = true, genericType = "java.lang.Long")
    @CustomerNotModify
    private List<Long> customerIdList;

    @ApiModelProperty(value = "保存的全部查询条件")
    @Lob
    @Column(columnDefinition = "text")
    @CustomerNotModify
    private String userSearchCondition;

    @ApiModelProperty(value = "使用了哪些优惠券")
    @Transient
    @FieldMapping(desField = "ticketJson", serialize = true, genericType = "com.xishu.bo.TicketAndLimit")
    @CustomerNotModify
    @DefaultValue(defaultValue = "")
    private List<TicketAndLimit> ticketAndLimitList;

    @ApiModelProperty(value = "使用了哪些优惠券")
    @FieldMapping(desField = "ticketAndLimitList", serialize = false, genericType = "com.xishu.bo.TicketAndLimit")
    @CustomerNotModify
    @Lob
    @Column(columnDefinition = "MEDIUMTEXT")
    private String ticketJson;

    @Transient
    @ApiModelProperty(value = "优惠券对象列表")
    @CustomerNotModify
    private List<DiscountTicket> ticketList;

    @ApiModelProperty(value = "在查询条件中多少人有电话号码")
    @CustomerNotModify
    private Long phoneUserCount;

    @ApiModelProperty(value = "在查询条件中多少人有邮件")
    @CustomerNotModify
    private Long emailUserCount;

    @ApiModelProperty(value = "任务的执行次数,按照发送的人数来算")
    @CustomerNotModify
    private Integer executeTime;

    @ApiModelProperty(value = "任务状态，0表示进行中，1表示停止")
    private Integer status;

    @ApiModelProperty(value = "会员查询列表")
    @Transient
    @FieldMapping(serialize = true, desField = "customerJson", genericType = "com.xishu.entity.customer.Customer")
    @CustomerNotModify
    private List<Customer> customerList;

    @ApiModelProperty(value = "会员查询列表")
    @FieldMapping(serialize = false, desField = "customerList", genericType = "com.xishu.entity.customer.Customer")
    @Lob
    @Column(columnDefinition = "MEDIUMTEXT")
    @CustomerNotModify
    private String customerJson;

    @ApiModelProperty(value = "总人数")
    @CustomerNotModify
    private Long totalNumber;

    @ApiModelProperty(value = "实际人数")
    @CustomerNotModify
    private Integer realNumber;

    @ApiModelProperty(value = "中文查询条件")
    @Lob
    @Column(columnDefinition = "MEDIUMTEXT")
    @CustomerNotModify
    private String queryString_zh;

    @ApiModelProperty(value = "英文查询条件")
    @Lob
    @Column(columnDefinition = "MEDIUMTEXT")
    @CustomerNotModify
    private String queryString_en;

    @ApiModelProperty(value = "邮件发送的条数")
    @Search(ignore = true)
    private int emailSendCount;

    @ApiModelProperty(value = "短信发送的条数")
    @Search(ignore = true)
    private int phoneSendCount;

    public Boolean getSmsZh() {
        return smsZh;
    }

    public void setSmsZh(Boolean smsZh) {
        this.smsZh = smsZh;
    }

    public Boolean getSmsEn() {
        return smsEn;
    }

    public void setSmsEn(Boolean smsEn) {
        this.smsEn = smsEn;
    }

    public int getEmailSendCount() {
        return emailSendCount;
    }

    public void setEmailSendCount(int emailSendCount) {
        this.emailSendCount = emailSendCount;
    }

    public int getPhoneSendCount() {
        return phoneSendCount;
    }

    public void setPhoneSendCount(int phoneSendCount) {
        this.phoneSendCount = phoneSendCount;
    }

    public String getQueryString_zh() {
        return queryString_zh;
    }

    public void setQueryString_zh(String queryString_zh) {
        this.queryString_zh = queryString_zh;
    }

    public String getQueryString_en() {
        return queryString_en;
    }

    public void setQueryString_en(String queryString_en) {
        this.queryString_en = queryString_en;
    }

    public Long getTotalNumber() {
        return totalNumber;
    }

    public void setTotalNumber(Long totalNumber) {
        this.totalNumber = totalNumber;
    }

    public Integer getRealNumber() {
        return realNumber;
    }

    public void setRealNumber(Integer realNumber) {
        this.realNumber = realNumber;
    }

    public String getCustomerJson() {
        return customerJson;
    }

    public void setCustomerJson(String customerJson) {
        this.customerJson = customerJson;
    }

    public List<Customer> getCustomerList() {
        return customerList;
    }

    public void setCustomerList(List<Customer> customerList) {
        this.customerList = customerList;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public Integer getExecuteTime() {
        return executeTime;
    }

    public void setExecuteTime(Integer executeTime) {
        this.executeTime = executeTime;
    }

    public Boolean getPeriodTask() {
        return periodTask;
    }

    public void setPeriodTask(Boolean periodTask) {
        this.periodTask = periodTask;
    }

    public Long getEmailUserCount() {
        return emailUserCount;
    }

    public void setEmailUserCount(Long emailUserCount) {
        this.emailUserCount = emailUserCount;
    }

    public Long getPhoneUserCount() {
        return phoneUserCount;
    }

    public void setPhoneUserCount(Long phoneUserCount) {
        this.phoneUserCount = phoneUserCount;
    }

    public List<TicketAndLimit> getTicketAndLimitList() {
        return ticketAndLimitList;
    }

    public void setTicketAndLimitList(List<TicketAndLimit> ticketAndLimitList) {
        this.ticketAndLimitList = ticketAndLimitList;
    }

    public String getTicketJson() {
        return ticketJson;
    }

    public void setTicketJson(String ticketJson) {
        this.ticketJson = ticketJson;
    }

    public List<DiscountTicket> getTicketList() {
        return ticketList;
    }

    public void setTicketList(List<DiscountTicket> ticketList) {
        this.ticketList = ticketList;
    }

    public String getCustomerIdListJson() {
        return customerIdListJson;
    }

    public void setCustomerIdListJson(String customerIdListJson) {
        this.customerIdListJson = customerIdListJson;
    }

    public List<Long> getCustomerIdList() {
        return customerIdList;
    }

    public void setCustomerIdList(List<Long> customerIdList) {
        this.customerIdList = customerIdList;
    }

    public String getUserSearchCondition() {
        return userSearchCondition;
    }

    public void setUserSearchCondition(String userSearchCondition) {
        this.userSearchCondition = userSearchCondition;
    }

    public Long getCompanyId() {
        return companyId;
    }

    public void setCompanyId(Long companyId) {
        this.companyId = companyId;
    }

    public String getTaskName_zh() {
        return taskName_zh;
    }

    public void setTaskName_zh(String taskName_zh) {
        this.taskName_zh = taskName_zh;
    }

    public String getTaskName_en() {
        return taskName_en;
    }

    public void setTaskName_en(String taskName_en) {
        this.taskName_en = taskName_en;
    }

    public Boolean getEmail() {
        return email;
    }

    public void setEmail(Boolean email) {
        this.email = email;
    }

    public Boolean getSms() {
        return sms;
    }

    public void setSms(Boolean sms) {
        this.sms = sms;
    }

    public String getEmailTitle() {
        return emailTitle;
    }

    public void setEmailTitle(String emailTitle) {
        this.emailTitle = emailTitle;
    }

    public String getEmailContent() {
        return emailContent;
    }

    public void setEmailContent(String emailContent) {
        this.emailContent = emailContent;
    }

    public Long getSmsId() {
        return smsId;
    }

    public void setSmsId(Long smsId) {
        this.smsId = smsId;
    }

    public Boolean getAutoSend() {
        return autoSend;
    }

    public void setAutoSend(Boolean autoSend) {
        this.autoSend = autoSend;
    }

    public PeriodTimeConfig getPeriodTimeConfig() {
        return periodTimeConfig;
    }

    public void setPeriodTimeConfig(PeriodTimeConfig periodTimeConfig) {
        this.periodTimeConfig = periodTimeConfig;
    }

    public String getPeriodTimeConfigJson() {
        return periodTimeConfigJson;
    }

    public void setPeriodTimeConfigJson(String periodTimeConfigJson) {
        this.periodTimeConfigJson = periodTimeConfigJson;
    }
}
